package com.tcoiss.kettle.admin;


import com.tcoiss.kettle.common.utils.IpUtil;
import com.tcoiss.kettle.core.init.EnableEtlKettle;
import org.mybatis.spring.annotation.MapperScan;
import org.pentaho.di.core.annotations.CarteServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 启动类
 *
 * {@code @EnableJpaAuditing} 该注解可以使得jpa自动生成创建时间和修改时间
 * {@code @EnableEtlKettle} 该注解初始化kettle
 * @author lyf
 */
@SpringBootApplication
@EnableJpaAuditing
@EnableScheduling
@CarteServlet(id = "test", name = "test")
@MapperScan("com.tcoiss.kettle.service.mapper")
public class KettleAdminApplication {

    public static void main(String[] args) {

        // 获取 Spring Boot 上下文
        ConfigurableApplicationContext applicationContext = SpringApplication.run(KettleAdminApplication.class, args);
        Environment env = applicationContext.getEnvironment();

        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");

        String ip = IpUtil.getIp();
        System.out.println("\n----------------------------------------------------------\n\t" +
                "Application kettle-scheduler-boot is running! Access URLs:\n\t" +
                "Local: \t\thttp://47.108.253.55:" + port + path + "\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "swagger-ui: \thttp://" + ip + ":" + port + path + "swagger-ui.html\n\t" +
                "----------------------------------------------------------");
    }
}
